import { defineStore } from "pinia";
import { ref } from "vue";
import { https } from "@/api/api";
import { showToast } from "@/public";
const useAddressStore = defineStore("addressStore", () => {
  //记录要要编辑的 信息
  const info = ref<AddressItem>();
  const addressList = ref([{
    name:'王小二',
    iphone:'137254627',
    id:'1',
  },{
    name:'王小三',
    iphone:'137254627',
    id:'2',
  },{
    name:'王小四',
    iphone:'137254627',
    id:'3',
  },{
    name:'王小五',
    iphone:'137254627',
    id:'4',
  }]);
  // 获取address列表
  const apiAddressList = async () => {
    const res = await https({
      mode: "address",
      name: "apiAddressList",
    });
    if (res.code !== 0) return showToast(res.msg);
    addressList.value = res.data.list;
  };
  return {
    info,
    addressList,
    apiAddressList,
  };
});
export default useAddressStore;
